<template>
  <div class="showImgCont">
    <div
      class="imgItem"
      :key="index"
      @click="showFn"
      v-for="(item, index) in propImg"
    >
      <img :src="item" title="点击查看" />
    </div>
    <div class="maskImg" v-if="showImg">
      <div class="maskImgCenter">
        <el-carousel :autoplay="false" height="600px">
          <el-carousel-item v-for="item in propImg" :key="item">
            <img style="height: 100%" :src="item" />
          </el-carousel-item>
        </el-carousel>
        <div class="closeBtn" @click="showImg = false">关闭</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      showImg: false,
    };
  },
  props: {
    propImg: {
      type: Array,
      default: [],
    },
    src: String,
    height: String,
  },
  methods: {
    showFn() {
      this.showImg = true;
    },
  },
  mounted() {
    window.addEventListener("keydown", (e) => {
      if (e.keyCode == 27) {
        this.showImg = false;
      }
    });
  },
  created() {},
};
</script>

<style scoped lang="less">
.showImgCont {
  display: flex;
  flex-wrap: wrap;
  .imgItem {
    margin-right: 10px;
    margin-bottom: 10px;
    background-color: #fff;
    padding: 2px;
    box-sizing: border-box;
    height: 100px;
    img {
      height: 100%;
    }
  }
  .maskImg {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    z-index: 999;
    position: fixed;
    top: 0;
    background-color: rgba(0, 0, 0, 0.3);
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    .maskImgCenter {
      width: 500px;
    }
    .closeBtn {
      position: absolute;
      right: 100px;
      top: 100px;
      width: 100px;
      line-height: 40px;
      background-color: #fff;
      color: black;
      font-size: 14px;
      text-align: center;
      cursor: pointer;
      border-radius: 5px;
    }
  }
}
</style>
